package com.sunqianhu.design_patterns_23.structural.flyweight;

import java.lang.Character;
import java.util.HashMap;
import java.util.Map;

public class CharacterFactory {
    private Map<Character, MyCharacter> characters = new HashMap<>();

    public MyCharacter getCharacter(char key) {
        MyCharacter character = characters.get(key);
        if (character == null) {
            character = new ConcreteMyCharacter(key);
            characters.put(key, character);
        }
        return character;
    }
}
